export default {
  state: {
    getIdtoMy: []
  },
  getters: {

  },
  actions: {
    getIdfuc ({ commit }, id) {
      console.log('1234111')
      console.log(this)
      fetch(`/xiaoliang/book-info/${id}`)
        .then(res => res.json())
        .then((data) => {
          console.log(data)
          commit('changeemitId', data)
        })
    }
  },
  mutations: {
    changeemitId (state, data) {
      console.log('11', data)
      console.log(state.getIdtoMy)
      state.getIdtoMy = JSON.parse(localStorage.getItem('bookself'))
      state.getIdtoMy.push({id: data._id, cover: data.cover, title: data.title})
      localStorage.setItem('bookself', JSON.stringify(state.getIdtoMy))
    }
  }
}
